{template 'common/header'}
{if $operation == 'display'}
<a href="{php echo $this->createWebUrl('video',array('op' =>'post'))}" class="btn btn-success"><i class="fa fa-plus"></i> 添加视频</a>
<div class="panel panel-info" style="margin-top: 10px;">
	<div class="panel-heading">搜索</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
			<input type="hidden" name="c" value="site" />
			<input type="hidden" name="a" value="entry" />
			<input type="hidden" name="m" value="hellozjx_mapwxapp" />
			<input type="hidden" name="do" value="video"/>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
				<div class="col-sm-8 col-lg-9 col-xs-12">
					<input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}" placeholder="输入视频名称">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
				<div class="col-sm-5 col-xs-12">
					<button class="btn btn-success"><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>
		</form>
	</div>
</div>
<div class="main panel panel-default">
	<div class="panel-body table-responsive">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:30px;">ID</th>
					<th style="text-align: center;">显示顺序</th>
					<th style="text-align: center;">视频名称</th>
					<th style="text-align: center;">展示图片</th>
					<th style="text-align: center;">课堂</th>
					<th style="text-align: center;">点击次数</th>
					<th style="text-align: center;">价格</th>
					<th style="text-align: center;">是否收费</th>
					<th style="text-align: center;">状态</th>
					<th style="text-align: center;">操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $item}
				<tr>
					<td style="vertical-align: inherit;">{$item['id']}</td>
					<td style="text-align: center;vertical-align: inherit;">{$item['sort']}</td>
					<td style="text-align: center;vertical-align: inherit;">{$item['name']}</td>
					<td style="text-align: center;vertical-align: inherit;"><img width="100" src="{php echo tomedia($item['img_url'])}" alt=" "></td>
					<td style="text-align: center;vertical-align: inherit;">{$item['m_name']}</td>
					<td style="text-align: center;vertical-align: inherit;">{$item['click']}</td>
					<td style="text-align: center;vertical-align: inherit;">{$item['price']}</td>
					<td style="text-align: center;vertical-align: inherit;">{if $item['is_charge']==1}是{else}否{/if}</td>
					<td style="text-align: center;vertical-align: inherit;">{if $item['status']== 2}上架{else}下架{/if}</td>
					<td style="text-align:center;font-size: 10px;vertical-align: inherit;">
						<a href="{php echo $this->createWebUrl('video', array('op' => 'post', 'id' => $item['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改"><i class="fa fa-edit"></i></a>
						<a href="{php echo $this->createWebUrl('video', array('op' => 'delete', 'id' => $item['id']))}" onclick="return confirm('确认删除吗？');return false;" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>
					</td>
				</tr>
				{/loop}
			</tbody>
		</table>
		{$pager}
	</div>
</div>
{elseif $operation == 'post'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
		<div class="panel panel-default">
			<div class="panel-heading">
				信息
			</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="sort" class="form-control" value="{$video['sort']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否上架</label>
					<div class="col-sm-9 col-xs-12">
						<label class='radio-inline'>
							<input type='radio' name='status' value='1' {if $video['status']==1}checked{/if} /> 否
						</label>
						<label class='radio-inline'>
							<input type='radio' name='status' value='2' {if $video['status']==2}checked{/if} /> 是
						</label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>所属教师</label>
					<div class="col-sm-9 col-xs-12">
						<select class="form-control" name="teacher_id">
							<option value="0">全部</option>
							{loop $teacher $row}
							<option value="{$row['id']}" {if $video['t_id'] == $row['id']}selected{/if}>{$row['name']}</option>
							{/loop}
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>所属课程</label>
					<div class="col-sm-9 col-xs-12">
						<select class="form-control" name="course_id">
							<option value="0">全部</option>
							{loop $subject $row}
							<option value="{$row['id']}" {if $video['s_id'] == $row['id']}selected{/if}>{$row['name']}</option>
							{/loop}
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>所属课堂</label>
					<div class="col-sm-9 col-xs-12">
						<select class="form-control" name="room_id">
							<option value="0">全部</option>
							{loop $class $row}
							<option value="{$row['id']}" {if $video['m_id'] == $row['id']}selected{/if}>{$row['name']}</option>
							{/loop}
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>视频名称</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='name' name="name" class="form-control" value="{$video['name']}" />
					</div>
				</div>
				<div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">展示图片</label>
                    <div class="col-sm-9 col-xs-12">
						{php echo tpl_form_field_image('img_url',$video['img_url']);}
                    </div>
                </div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>视频地址</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='video_url' name="video_url" class="form-control" value="{$video['video_url']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否免费</label>
					<div class="col-sm-9 col-xs-12">
						<label class='radio-inline'>
							<input type='radio' name='is_charge' value='1' {if $video['is_charge']==1}checked{/if} /> 否
						</label>
						<label class='radio-inline'>
							<input type='radio' name='is_charge' value='0' {if $video['is_charge']==0}checked{/if} /> 是
						</label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>价格</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='price' name="price" class="form-control" value="{$video['price']}" />
					</div>
				</div>
            </div>
		</div>
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="id" value="{$video['id']}" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>
<script language='javascript'>
	function formcheck() {
		if ($("#name").val() == '') {
			util.message("请输入名称");
			return false;
		}
		if ($("#address").val() == '') {
			util.message("请填写地址");
			return false;
		}
		if($('is_charge').val() == 1){
			if ($("#price").val() == '') {
				util.message("请填写价格");
				return false;
			}
		}
		return true;
	}
</script>
{/if}

{template 'common/footer'}